package com.example.equipmentmanage.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.equipmentmanage.R

import com.example.equipmentmanage.entity.SheBeiEntityItem
import com.example.lib_base.BaseApp

class SheBeiAdapter:BaseQuickAdapter<SheBeiEntityItem,BaseViewHolder>(R.layout.shebei_layout) {
    override fun convert(helper: BaseViewHolder, item: SheBeiEntityItem) {
        helper.setText(R.id.tv_title,item.deviceName)
        helper.setText(R.id.tv_type,"设备类型：${item.deviceType}")
        helper.setText(R.id.tv_location,"安装地点：${item.installationLocation}")
        helper.setText(R.id.tv_gpl,"故障率：${item.failureRate}")
        helper.setText(R.id.tv_status,item.status)


        when (item.status) {
            "正常" -> {
                helper.getView<TextView>(R.id.tv_status).setTextColor(BaseApp.context.resources.getColor(R.color.green))
                helper.getView<TextView>(R.id.tv_status).setBackgroundResource(R.drawable.xianxianllllln)

            }
            "故障" -> {
                helper.getView<TextView>(R.id.tv_status).setTextColor(BaseApp.context.resources.getColor(R.color.orange))
                helper.getView<TextView>(R.id.tv_status).setBackgroundResource(R.drawable.xinlllllsn)

            }
        }
    }
}

class SheBeiSearchAdapter:BaseQuickAdapter<SheBeiEntityItem,BaseViewHolder>(R.layout.shebei_layout) {
    override fun convert(helper: BaseViewHolder, item: SheBeiEntityItem) {
        helper.setText(R.id.tv_title,item.deviceName)
        helper.setText(R.id.tv_type,"设备类型：${item.deviceType}")
        helper.setText(R.id.tv_location,"安装地点：${item.installationLocation}")
        helper.setText(R.id.tv_gpl,"故障率：${item.failureRate}")
        helper.setText(R.id.tv_status,item.status)


        when (item.status) {
            "正常" -> {
                helper.getView<TextView>(R.id.tv_status).setTextColor(BaseApp.context.resources.getColor(R.color.green))
                helper.getView<TextView>(R.id.tv_status).setBackgroundResource(R.drawable.xianxianllllln)

            }
            "故障" -> {
                helper.getView<TextView>(R.id.tv_status).setTextColor(BaseApp.context.resources.getColor(R.color.orange))
                helper.getView<TextView>(R.id.tv_status).setBackgroundResource(R.drawable.xinlllllsn)

            }
        }
    }
}